package com.lxj.charactor;

/**
 * Hero
 */
public class Hero {
    public int id;
    public String name;
    public float hp;
    public float damage;

    public Hero() {
        
    }
    public Hero(String name) {
        this.name = name;
    }

    public Hero(String name, float hp, float damage) {
        this.name = name;
        this.hp = hp;
        this.damage = damage;

    }

    public Hero(int id,String name, float hp, float damage) {
        this.id = id;
        this.name = name;
        this.hp = hp;
        this.damage = damage;
    }

    public void attackHero(Hero h) {
        try {
            Thread.sleep(1000);
        } catch (Exception e) {
            e.printStackTrace();
        }

        h.hp -= damage;
        System.out.format("%s 正在攻击 %s, %s的血编程了%.0f%n", name, h.name, h.name, h.hp);
        if(h.isDead()) {
            System.out.println(h.name + "死了");
        }
    }

    public boolean isDead() {
        return 0 >= hp ? true : false;
    }
}